package com.woniu.job.controller;

import com.woniu.job.entity.Admin;
import com.woniu.job.entity.Category;
import com.woniu.job.entity.vo.ResponseVO;
import com.woniu.job.service.ICategoryService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author sunnylausong
 *
 * 2019/12/24
 * 20:07
 */


@RestController
@RequestMapping("/category")
@SessionAttributes("loginAdmin")
@Api("后台管理员接口")
public class CategoryController {

    @Autowired
    ICategoryService categoryService;


/**
* @Description:添加职位
* @author 苏小
* @since 2019/12/27
*/

    @PostMapping("/add")
    public ResponseVO<Category> add(@RequestBody Category category,@SessionAttribute("loginAdmin")Admin admin)
    {

           return new  ResponseVO<>("200","添加成功",categoryService.add(category));

    }
/**
* @Description:更改职位状态，删除职位
* @author 苏小
* @since 2019/12/27
*/

    @PostMapping("/del/{id}")
    public ResponseVO<String> del (@PathVariable("id") String id,@SessionAttribute("loginAdmin")Admin admin) {
        categoryService.del(id );
        return new ResponseVO<>("200","删除成功","");
    }

/**
* @Description:物理删除
* @author 苏小
* @since 2019/12/27
*/

    @PostMapping("/realDel/{id}")
    public ResponseVO<String> realDel (@PathVariable("id") String id,@SessionAttribute("loginAdmin")Admin admin) {
        categoryService.realDel(id);
        return new ResponseVO<>("200","删除成功","");
    }


    /**
    * @Description:查询所有职位
    * @author 苏小
    * @since 2019/12/27
    */

    @GetMapping("/list")
    public ResponseVO<List<Category>> list() {

    return  new ResponseVO<>("200","nice",categoryService.getAll());
    }





}
